1. Field of the Invention
The present invention relates to virtualization technology, and, more particularly, to memory management for Virtual Machines.
2. Background Art
With Virtual Machine (VM) technology, a user can create and run multiple operating environments on a server at the same time. Each virtual environment, or Virtual Machine, requires its own operating system (OS) and can run applications independently. The VM software provides a layer between the computing, storage, and networking hardware and the software that runs on it.
Virtual Machine technology can lower information technology (IT) cost through increased efficiency, flexibility, and responsiveness. Each VM acts as a separate execution environment, which reduces risk and allows developers to quickly re-create different operating system (OS) configurations or compare versions of applications designed for different OS's. Additional uses for VMs include targeted production server consolidation, hosting of legacy applications (older versions), and computer or server backup.
Virtual Machine technology is therefore one technique for emulating or otherwise virtualizing the behavior of software and/or hardware. Generally, a Virtual Machine is an environment that is launched on a particular processor that is running a host operating system (HOS). Normally, the operating system installed on such a machine or processor has certain privileges that are not available to user applications. For example, many input/output commands may be privileged, and executable only in the operating system (or privileged) mode. Certain areas of memory, or certain addresses in memory, also may require operating system privilege to be accessed.
For each VM, a separate process is created, and the HOS is responsible for scheduling of both the VMs and other processes in the HOS. Examples of such hosted VMMs include VMware GSX Server, VMware Workstation, MS Virtual PC, MS Virtual Server and SVISTA 2004.
Throughout this discussion, it will also be assumed that the reader is generally familiar with the various addressing modes of the Intel™ processor architecture, as well as with virtualization techniques for the Intel™ family of processors. Generally, the Intel™ architecture has a number of relatively complex addressing schemes, all of which can be used by the processor at various times.
Furthermore, due to the need to support legacy software, over the years, the Intel™ architecture has grown increasingly complex, and therefore, increasingly difficult to virtualize. The practical consequence of this is that the performance of the virtualized operating system is frequently significantly slower than the performance of a non-virtualized code. One of the reasons for this involves the paging structures used by the operating system, and the need to virtualize them.
In the context of virtualization, the problem exists in having to efficiently map the paging structures of the guest operating system (GOS) to the paging structures of the Virtual Machine Monitor (VMM). As far as the GOS is concerned, this must be entirely transparent, however, the amount of physical memory that the GOS “really” has is usually much less than the amount of physical memory that the GOS “thinks” it has. This may be due to the fact that some of the memory is allocated to the VMM and to the host operating system.
It may be due to the fact that several Virtual Machines are running at the same time, and the physical memory therefore needs to be allocated between them by the host OS and/or VMM. The consequence of this is that very frequently, guest code running in a particular Virtual Machine will attempt to access a page in memory that the Virtual Machine thinks is mapped into linear space, however, in reality, that page is marked as “not present” and therefore absent in paging translation. This triggers a page fault, throwing control to the VMM, which needs to handle the page fault.
The problem of mapping between guest paging structures and VMM paging structures is something that has significant efficiency implications, because it is an overhead-intensive process. Thus, to improve the efficiency of the Virtual Machine, the number of page faults needs to be minimized and the amount of overhead associated with each page fault needs to be minimized as well. At the same time sufficient protection of paging tables needs to be provided.
Accordingly, there is a need in the art for an efficient mechanism for handling page faults and protecting paging tables in the context of virtualization technology.